package com.litxuf.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.litxuf.FinalInformation;
import com.litxuf.logic.member.dao.model.School;

public class MemberLogoutServlet extends HttpServlet {
	Logger logger = Logger.getLogger(this.getClass());

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		super.doGet(req, resp);
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(req, resp);
	}

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		School sm = (School) request.getSession().getAttribute(
				FinalInformation.UserFrontLogin);

		if (sm == null) {
			response.sendRedirect(request.getContextPath() + "/login.jsp");
		}
		 
		// 2.注销Session
		request.getSession().invalidate();

		try {
			logger.info(" -->用户退出系统 成功");
			response.sendRedirect(request.getContextPath() + "/login.jsp");
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
